-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add other client extensions #637
base: main
Are you sure you want to change the base?
Conversation
Refactor to use interfaces for enhanced flexibility and testability across various components like NatsJSContext and NatsConnection. Added new extension methods to easily create contexts for Object Store, Key-Value Store, and Services on NATS client and connection instances.
Updated INatsObjStore, INatsKVContext, and INatsSvcContext interfaces to include public `Context` properties. This change ensures consistent access to the underlying context objects across various components.
🙌 looking forward to this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. All comments are thought provoking.
/// <summary> | ||
/// Provides access to the JetStream context associated with the Key-Value Store operations. | ||
/// </summary> | ||
INatsJSContext Context { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, but wondering what you think about folks using code like
var context = client.CreateKeyValueStoreContext();
...
var jsContext = context.Context;
I don't mind it, but the thought came to mind and figured I'd mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about JetStreamContext
or just JetStream
?
var context = client.CreateKeyValueStoreContext();
...
var jsContext = context.JetStreamContext;
...
var jsContext = context.JetStream;
public NatsKVContext(NatsJSContext context) => _context = context; | ||
public NatsKVContext(INatsJSContext context) => Context = context; | ||
|
||
/// <inheritdoc /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My OCD thanks you for this. Prob don't need to, but could do the rest while you're here. ;) Might make sense as a separate maintenance PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean using the new type constructors (or whatever they're called)?
/// <param name="client">The NATS client instance.</param> | ||
/// <returns>An instance of <see cref="INatsKVContext"/> which can be used to interact with the Key-Value Store.</returns> | ||
public static INatsKVContext CreateKeyValueStoreContext(this INatsClient client) | ||
=> CreateKeyValueStoreContext(client.Connection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to chain these to the JS extensions?
public static INatsKVContext CreateKeyValueStoreContext(this INatsClient client)
=> CreateKeyValueStoreContext(client.CreateJetStreamContext());
public static INatsKVContext CreateKeyValueStoreContext(this INatsConnection connection)
=> CreateKeyValueStoreContext(connection.CreateJetStreamContext());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense 💯 done
Refactor to use interfaces for enhanced flexibility and testability across various components like NatsJSContext and NatsConnection. Added new extension methods to easily create contexts for Object Store, Key-Value Store, and Services on NATS client and connection instances.